package net.coding.bamboo.wex.mq.processor.impl;

import com.weihui.finance.fundmanage.domain.model.LoanResult;
import com.weihui.finance.fundmanage.domain.model.LoanResultMessage;
import net.coding.bamboo.wex.mq.processor.LoanResultMessageService;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import java.util.List;

/**
 * @author : zenghua
 * @version : v0.1 LoanResultMessageServiceImpl.java
 * @since : 2017/7/17 16:04
 */
@Component("loanResultMessageService")
public class LoanResultMessageServiceImpl implements LoanResultMessageService {
    public static final Logger LOGGER = LoggerFactory.getLogger(LoanResultMessageServiceImpl.class);

    public static final String KSRCB_FUND_PARTNER_ID = "200003670082";

    @Override
    public void process(LoanResultMessage loanResultMessage) {
        List<LoanResult> loanResultList = loanResultMessage.getLoanResultList();
        Assert.notNull(CollectionUtils.isNotEmpty(loanResultList), "放款消息结果列表不能为空");
        LOGGER.info("放款结果消息处理开始");
        for (LoanResult loanResult : loanResultList) {
            if (!KSRCB_FUND_PARTNER_ID.equals(loanResult.getPartnerId())) {
                System.out.println(loanResult);
            }
        }
        LOGGER.info("放款结果消息处理结束");
    }
}
